package com.javaee.ioc.annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class Car {
    @Qualifier("v6Engine")
    @Autowired
    private Engine engine;

    //设置汽车引擎
    public Engine getEngine(){
        return engine;
    }

    public void setEngine(Engine engine){
        this.engine = engine;
    }

    @Override
    public String toString(){
        return "Car{" + "engine=" + engine + '}';
    }

    public void run(){
        engine.run();
    }
}
